﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SCRUM.Core.DataProviders;
using SCRUM.Core.BusinessObjects;

namespace SCRUM.Core.DAO
{
    /// <summary>
    /// Static access object for handling sprints
    /// </summary>
    public static class DAOSprint
    {
        /// <summary>
        /// Creates the specified sprint.
        /// </summary>
        /// <param name="sprint">The specific sprint.</param>
        /// <param name="releaseId">Sprint is in release</param>
        /// <returns>Created sprint</returns>
        public static Sprint CreateNewSprint(Sprint sprint, int releaseId)
        {
            return ProviderFactory.Provider.CreateSprint(sprint, releaseId);
        }

        /// <summary>
        /// Updates the specified sprint.
        /// </summary>
        /// <param name="sprint">The specific sprint.</param>
        /// <param name="releaseId">Sprint is in release</param>
        public static void UpdateSprint(Sprint sprint, int releaseId)
        {
            ProviderFactory.Provider.UpdateSprint(sprint, releaseId);
        }

        /// <summary>
        /// Deletes the specified sprint.
        /// </summary>
        /// <param name="sprint">The specific sprint.</param>
        public static void DeleteSprint(Sprint sprint)
        {
            ProviderFactory.Provider.DeleteSprint(sprint.ID);
        }

        /// <summary>
        /// Deletes the sprint.
        /// </summary>
        /// <param name="sprintID">The sprint ID.</param>
        public static void DeleteSprint(int sprintID)
        {
            ProviderFactory.Provider.DeleteSprint(sprintID);
        }

        /// <summary>
        /// Returns sprint according to its id
        /// </summary>
        /// <param name="sprintId">ID of the sprint.</param>
        /// <returns>Sprint specified by ID.</returns>
        public static Sprint GetSprintById(int sprintId)
        {
            return ProviderFactory.Provider.GetSprintById(sprintId);
        }

        /// <summary>
        /// Gets the sprint by userStoryID.
        /// </summary>
        /// <param name="userStoryID">ID of the UserStory.</param>
        /// <returns>sprint containing that user story</returns>
        public static Sprint GetSprintByUserStoryID(int userStoryID)
        {
            return ProviderFactory.Provider.GetSprintByUserStoryID(userStoryID);
        }

        /// <summary>
        /// Gets all sprints for specific release.
        /// </summary>
        /// <param name="releaseID">All sprints in release with this id</param>
        /// <returns>List with all sprints for the release.</returns>
        public static IList<Sprint> GetAllSprintsForRelease(int releaseID)
        {
            return ProviderFactory.Provider.GetAllSprintsForRelease(releaseID);
        }

        /// <summary>
        /// Gets all sprints for specific project.
        /// </summary>
        /// <param name="projectID">All sprints in project with this id</param>
        /// <returns>List with all sprints for the project.</returns>
        public static IList<Sprint> GetAllSprintsForProject(int projectID)
        {
            return ProviderFactory.Provider.GetAllSprintsForProject(projectID);
        }

        /// <summary>
        /// Method without parameter gets all sprints
        /// </summary>
        /// <returns>all sprints</returns>
        public static IList<Sprint> GetAllSprints()
        {
            return ProviderFactory.Provider.GetAllSprints();
        }

        /// <summary>
        /// Gets all sprints.
        /// </summary>
        /// <param name="projectID">The project ID.</param>
        /// <param name="releaseID">The release ID.</param>
        /// <param name="sprintID">The sprint ID.</param>
        /// <param name="userStoryID">The user story ID.</param>
        /// <returns></returns>
        public static IList<Sprint> GetAllSprints(int projectID, int releaseID, int sprintID, int userStoryID)
        {
            return ProviderFactory.Provider.GetAllSprints(projectID, releaseID, sprintID, userStoryID);
        }

		/// <summary>
		/// Gets all future sprints.
		/// </summary>
		/// <returns>List of all task, which did not ended.</returns>
		public static IList<Sprint> GetAllFutureSprints()
		{
			return ProviderFactory.Provider.GetAllFutureSprints();
		}
    }
}
